﻿using AutoMapper;
using Modules.FaceScan.Entitys;
using Modules.Person;
using PmSoft;
using static Modules.CheckIn.CheckInDetailConstants;

namespace ManagementApi.Models.Person
{
    public class PersonFaceScanRecordDto
    {
        /// <summary>
        ///  
        ///</summary>
        public int Id { get; set; }

        /// <summary>
        /// 扫描来源类型名称 
        ///</summary>
        public string ReferTypeName { get; set; }
        /// <summary>
        /// 人员姓名
        ///</summary>
        public string PersonName { get; set; }
        /// <summary>
        /// 人脸认证身份证号码 
        ///</summary>
        public string IdCard { get; set; }
        /// <summary>
        /// 是否已确认 
        ///</summary>
        public bool IsConfirmed { get; set; }
        /// <summary>
        /// 确认时间 
        ///</summary>
        public DateTime? ConfirmTime { get; set; }
        /// <summary>
        /// 相似性 
        ///</summary>
        public float? Similarity { get; set; }
        /// <summary>
        /// 已通过识别 
        ///</summary>
        public bool IsPassed { get; set; }
        /// <summary>
        /// 验证时间 
        ///</summary>
        public DateTime? VerifyTime { get; set; }
        ///// <summary>
        ///// 头像图片地址 
        /////</summary>
        //public string CameraPhoto { get; set; }
        /// <summary>
        ///  识别时间
        ///</summary>
        public DateTime CreateTime { get; set; }
        /// <summary>
        ///  数据来源
        ///</summary>
        public 数据来源 DataSource { get; set; }
        /// <summary>
        ///  数据来源
        ///</summary>
        public string DataSourceName { get; set; }
    }

    public static partial class PersonFaceScanRecordExceptions
    {
        public static PersonFaceScanRecordDto AsDto(this FaceScanRecord entity)
        {
            PersonFaceScanRecordDto dto = new PersonFaceScanRecordDto();
            var mapper = ServiceAccessor.GetService<IMapper>();
            var personService = ServiceAccessor.GetService<PersonService>();
            mapper.Map(entity, dto);
            dto.ReferTypeName = entity.ReferType.GetDescription();
            dto.DataSourceName = entity.DataSource.GetDescription();
            dto.PersonName = personService.GetPersonByCardNo(entity.IdCard).Name;
            return dto;
        }
    }
}
